let baseUrl = '';

if (process.env.NODE_ENV === "development") {
	console.log('测试环境');
	//#ifndef APP-PLUS
		baseUrl = "http://localhost:8080"
	//#endif
	//#ifdef APP-PLUS
		baseUrl = "https://jc.mojiaqingti.com"
	//#endif
} else {
	console.log('生产环境');
	baseUrl = "https://jc.mojiaqingti.com"
}

export const request  = (options) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: baseUrl+'/index'+options.url,
			method: options.method || 'GET',
			header: {
				"Content-Type": "application/x-www-form-urlencoded",
				"UserType": 1,
				"Authorization": null,
				'mid': 1
			},
			data: options.data || {},
			success: (res) => {
				// console.log("请求成功");
				// console.log(res.statusCode);
				resolve(res.data)
			},
			fail: (err) => {
				// 页面中弹框显示失败
				uni.showToast({
					title: '请求接口失败'
				})
				console.log(err);
				// 返回错误消息
				reject(err)
			},
			complete: () => {}
		});
	})
}

export default request;